<script setup lang="ts">
import {onBeforeMount, ref} from 'vue';
import zh from "ant-design-vue/locale/zh_CN"
import _ from "lodash";
import {delCookie, getCookie} from "@/util/cookieUtil";
import {userConfigStore} from "@/store/user/userConfigStore";
import {AppConsoleLog, ECode} from "@/util/commonUtil";
import {authVerify} from "@/api/user/user";
import {cookieToken} from "@/config/CookieConfig";
import Loading from "@/components/loading/loading2.vue"
// import {useOml2d} from "@/plugins/useOml2d";
// 圆角
const borderRadius = ref(6)


onBeforeMount(async () => {
  // 检查是否登录
  await getTokenByUrl()
  AppConsoleLog()
})
// 画板娘
// useOml2d()

async function getTokenByUrl() {
  let token: any = getCookie(cookieToken);
  if (!_.isNull(token)) {
    await authVerify(token).then((response: any) => {
      if (response.code === ECode.SUCCESS) {
        console.log("AppAuthVerify===>成功!")
        userConfigStore().setLoginState(true)
        userConfigStore().setUserInfo(response.data)
        userConfigStore().setAuthCode(response.data.authCodeList)
      } else {
        userConfigStore().setLoginState(false)
        delCookie(cookieToken);
      }
    })
  }
}
</script>

<template>
  <a-config-provider
      :theme="{token: {borderRadius: borderRadius,},}"
      :locale="zh">
    <Loading/>
    <!--- 路由 -->
    <RouterView/>
  </a-config-provider>
</template>

<style scoped>

</style>
